<?php
	class UserModel extends Model{
		public $_validate =	array(
				array('user','/^[a-z]\w{2,20}$/i','帐号格式错误'),
				array('password','6,12','密码长度必须在6-12位之间',Model::VALUE_VAILIDATE,'length'),
				array('repwd','require','确认密码必须'),
				array('repwd','password','确认密码不一致',self::EXISTS_VAILIDATE,'confirm'),
				array('email','email','邮箱格式不正确！'),
				array('verify','require','验证码必须填写！'),
				array('user','','帐号已经存在',self::EXISTS_VAILIDATE,'unique',self::MODEL_INSERT),
				array('email','','邮箱已经存在',self::EXISTS_VAILIDATE,'unique',self::MODEL_INSERT),
		);
		
		public $_auto =	array(
				array('password','md5',self::MODEL_BOTH,'function'),
				array('reg_time','time',self::MODEL_INSERT,'function'),
				array('login_time','time',self::MODEL_INSERT,'function'),
				array('password','chkEmpty',Model:: MODEL_UPDATE,'callback')
		);
		
		public function chkEmpty()
		{
			if(empty($_POST['pwd'])){
				$user = $this->field('password')->where('id = '.$_POST['id'])->find();
				return $user['password'];
			}
		
		}
	}

?>